/**
 * Created by yuzhou on 16/9/21.
 */

define(['vue','debug', 'text!tpl/mainSideBarMenu.html',
    'vuex/actions/user'
], function(Vue, Debug, mainSideBarMenuHtml, userAction) {

    var debug = Debug('App:Main:SideBar')

    return Vue.extend({
        template: mainSideBarMenuHtml,
        props: {
            model: Object
        },
        vuex: {
            actions: {
                updateTreeById: userAction.updateTreeById
            }
        },
        methods: {
            clickMe: function(event){
                if(this.model.children && this.model.children.length > 0) {
                    this.updateTreeById(this.model.id, !this.model.active)
                }
            }
        },
        components: {
        },
        ready: function(){
            debug('Main SideBar menu component is ready')
        }
    })
})